
//------------------------------ajax function ----------------------------
/**
 * ajax 请求
 * @param url
 * @param successFunc
 * @param errorFunc
 * @returns
 */
function getAjaxPage(url,successFunc,errorFunc){
	$.ajax({
		type : 'GET',
		url : url,
		contentType : "text/html",
		dataType : "html",
		async : true,
		success : function(data){
			successFunc(data);
         },
		error:errorFunc
	})
};

/**
 * @Func Ajax post 数据请求
 * @param dataurl
 * @param data
 * @param sucessCallBack
 * @param errorCallBack
 */
function postAjax(url, data,sucessCallBack, errorCallBack) {
	if(typeof(userKey)=="undefined"){
		userKey='';
	}
	$.ajax({
		type : "POST",
		url : url,
		contentType : "application/json",
		dataType : "json",
		async : true,
		headers : {
			'USER-KEY' :userKey 
		},
		data : JSON.stringify(data),
		success : function(data){
			if(data.status == 20000){
				return;
			}else{
				sucessCallBack(data);
			}
		},
		error : errorCallBack
	})
};

/**
 * @Func Ajax get 数据请求
 * @param dataurl
 * @param sucessCallBack
 * @param errorCallBack
 */
function getAjax(url, sucessCallBack, errorCallBack) {
	if(typeof(userKey)=="undefined"){
		userKey='';
	}
	$.ajax({
		type : "GET",
		url : url,
		contentType : "application/json",
		dataType : "json",
		async : true,
		headers : {
			'USER-KEY' :userKey 
		},
		success : function(data){
			sucessCallBack(data);
		},
		error : errorCallBack
	})
};

function commonAjax(method,url, data,sucessCallBack, errorCallBack) {
	var config = {
		type : method ,
		url : url,
		contentType : "application/json",
		dataType : "json",
		async : true,
		success : function(data){
			if(data.status == 20000){
				return;
			}else{
				sucessCallBack(data);
			}
		},
		error : errorCallBack
	};
	if(typeof(userKey) != "undefined"){
		config.headers={  'USER-KEY' :userKey  };
	}
	if(method.toUpperCase() != 'GET'){
		config.data = JSON.stringify(data);
	}
	$.ajax(config)
};

/**
 * 关闭微信页面
 * @param timeout
 * @returns
 */
function closeWeixinWindow(timeout){
	setTimeout(function(){WeixinJSBridge.call('closeWindow');},gdv(timeout,100));	
}


/**
 * 通过ajax请求服务器数据，生成select
 */
function init_select(object ){
	commonAjax( gdv(object.method,"POST") , 
		 localUrl + object.url , gdv(object.data,{}),function(data){
			$(object.selector).empty();
			if(data.status == 10001){
				var dataTemp = data.data.data ;
				if(! validater.empty(object.init_value) ){
					$(object.selector).append("<option value='' >"+ object.init_value +"</option>");
				}
				for(var i=0;i< dataTemp.length; i++){
					var tempOption = "<option "+ (dataTemp[i][gdv(object.key,"key")] == object.default_value ? "selected":"" )  +"  value='" + dataTemp[i][gdv(object.key,"key")]  +  "'>"+ dataTemp[i][gdv(object.value,"value")]  +"</option>"
					$(object.selector).append(tempOption);
				}
				object.success();
			}
	});
}

/**
 * 过滤器值
 */
var getVal = gdv ;
function gdv(value,default_val){
	if(value!="" && value!=undefined && value!='undefined'){
		return value ;
	}else{
		if(default_val != undefined)
			return default_val ;
		return "";
	}
};

var validater ={
		email:function(obj){
			var reg = /^([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+@([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+\.[a-zA-Z]{2,3}$/;
			if(!reg.test(obj)) {
			    return false ;
			}
			return true ;
		} ,
		phone:function(obj){
			var phone=/^((\+?86)|(\(\+86\)))?(13[0123456789][0-9]{8}|15[012356789][0-9]{8}|18[0123456789][0-9]{8}|17[0-9]{9}|147[0-9]{8}|1349[0-9]{7})$/;
			if(!phone.test(obj)){
			    return false;
			}
			return true ;
		},
		num:function(obj){
			if(!isNaN(obj)){
				return true ;
			}
			return false ;
		},
		character:function(obj){
			var Regx =  /^[A-Za-z]*$/;
			if(Regx.test(val)){
				return true ;
			}
			return false ;
		},
		chinese:function(obj){
			if(/^[\u4e00-\u9fa5]+$/i.test(obj)){
				return true ;
			}
			return false;
		},
		empty:function(obj){
			if(obj!="" && obj!=undefined && obj!="undefined"){
				return false;
			}
			return true ;
		},
		zero:function(obj){
			if(obj==0)
				return true ;
			return false ;
		},
		illegalChar:function(obj){
			var pattern=/[`~!@#\$%\^\&\*\(\)_\+<>\?:"\{\},\.\\\/;'\[\]]/im; 
			if(pattern.test(str)){ 
				return true; 
			} 
			return false; 
		}
}

function tom(flg,val,val2){
	return flg?val:val2 ;
}


/**
 * 通过ajax请求服务器数据，生成select
 */
function init_select(object,selector ){
	commonAjax( gdv(object.method,"POST") , 
		 localUrl + object.url , ( (object.method == 'GET')?'': (  objecter( gdv(object.data,{}),'$') )  ) ,function(data){
			gdv(selector,$(object.selector)).empty();
			if(data.status == status_code.OK){
				var dataTemp ;
				if(validater.empty(data.data)){
					return ;
				} 
				if(object.type == null ||object.type=='page' ){
					dataTemp = data.data.data ;					
				}else{
					dataTemp = data.data ;
				}
				if(! validater.empty(object.init_value) ){
					gdv(selector,$(object.selector)).append("<option value='' >"+ object.init_value +"</option>");
				}
				for(var i=0;i< dataTemp.length; i++){
					var tempOption = "<option "+ (dataTemp[i][gdv(object.key,"key")] == object.default_value ? "selected":"" )  +"  value='" + dataTemp[i][gdv(object.key,"key")]  +  "'>"+ dataTemp[i][gdv(object.value,"value")]  +"</option>"
					gdv(selector,$(object.selector)).append(tempOption);
				}
				if(!validater.empty(object.success) ){
					eval('('+ object.success +'()' +')');
				}
			}else{
				gdv(selector,$(object.selector)).append("<option value='' >"+ object.init_value +"</option>");
			}
	});
}

function disvalue(val,length){
	if(length >= val.length){
		return val ;
	}else{
		return val.substring(0,length)+"..";
	}
}

function convertControl(value,measure,device_status){
	if(measure ==null ){
		return "" ;
	}
	var str = measure.split(",");
	if(str.length!=2){
		return "";
	}
	for(var i=0;i<str.length;i++){
		if(str[i].indexOf(device_status) >-1 ){
			var subStr = str[i].split(":");
			if(subStr.length !=2){
				return "";
			}else{
				if(subStr[0] == value){
					// 满足
					if(i==0){
						return str[1].split(":")[0];
					}else{
						return str[0].split(":")[0];
					}
				}else{
					return "";
				}
			}
		}
	}
}

/**
 * @time
 * @Func 将长整形时间 转换制定格式
 * @param time 长整形数值
 * @returns {String}
 * @Exp time2Str("1464058102000","MM/dd hh:mm")
 */
function time2Str(time,format){
	if(time == "" || time == null)
		return ;
	if(format==undefined || format == "")
		format = "yyyy/MM/dd hh:mm:ss";
    var datetime = new Date();
    datetime.setTime(time);
    return datetime.Format(format);
};

/**
 * @time
 * @Func 时间格式化
 * @FuncName Format
 * (new Date()).Format("yyyy-MM-dd hh:mm:ss.S") ==> 2006-07-02 08:09:04.423 
 */
Date.prototype.Format = function (fmt) { 
	 var o = {
	     "M+": this.getMonth() + 1, 
	     "d+": this.getDate(), 
	     "h+": this.getHours(), 
	     "m+": this.getMinutes(), 
	     "s+": this.getSeconds(), 
	     "q+": Math.floor((this.getMonth() + 3) / 3), 
	     "S": this.getMilliseconds()
	 };
	 if (/(y+)/.test(fmt)) fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
	 for (var k in o)
		 if (new RegExp("(" + k + ")").test(fmt)) fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
	 return fmt;
};


function forward(url){
	window.location.href = localUrl + url ;
}

function isOK(data){
	if(data.status == status_code.OK){
		return true ;
	}else{
		return false ;
	}
}

/**
 * 去除没有匹配带的数值
 * @param s
 * @returns
 */
function removeformat(s){
	return s.replace(/\{([\w-*\.*]+)\}/g,function(m,i){ return "" ;} );
}

String.prototype.format = function() {
	if (arguments.length == 0)
		return this;
	var param = arguments[0];
	var s = this;
	if (typeof (param) == 'object') {
		for( var key in param){
			if(key == 'data'){
				for(var subKey in param.data){
					s = s.replace(new RegExp("\\{" + key + "." + subKey + "\\}", "g"), param.data[subKey]);  
				}
			}else{
				s = s.replace(new RegExp("\\{" + key + "\\}", "g"), param[key]);
			}
		}
		// 这边再对特殊数值进行处理
		// 处理方括号的data数值
		s = s.replace(/\[([\w-*\.*]+)\]/g,function(m,i){ 
			if(i.indexOf(".")>-1){
				var str = i.split(".");
				return time2Str(param[str[0]],str[1]);
			}else{
				return time2Str(param[i]);
			}
		});
		return removeformat(s);
	} else {
		for (var i = 0; i < arguments.length; i++)
			s = s.replace(new RegExp("\\{" + i + "\\}", "g"), arguments[i]);
		return s;
	}
}

/**
 * 分页的参数显示，复位
 * @returns
 */
function pagerorgin(){
	$(".no-more-data,.no-data").hide();
	$(".weui-loadmore").show();
}
/**
 * 分页信息显示
 * @returns
 */
function pagerinit(data,selector){
	if( $(selector).html()!=''  ){
		if(isOK(data)){
			if(data.data.data != null && data.data.data.length>0  ){
				// --
				if(data.data.paged == data.data.totalPage){
					$(".weui-loadmore").hide();
					if( data.data.totalCount> 4){
						$(".no-more-data").show();
					}
				}
			}else{
				$(".weui-loadmore").hide();
				if( data.data.totalCount> 4){
					$(".no-more-data").show();
				}
			}
		}else{
			$(".weui-loadmore").hide();
			if($(selector).children.length>4){
				$(".no-more-data").show();	
			}
			if($(selector).children.length ==0 || data.status == 4){
				$(".no-data").show();
			}
		}
	}else{
		$(".no-data").show();
		$(".weui-loadmore").hide();
	}
}

// 页面中图片可以自动放大
$(function(){
	$(".weui-media-box__thumb").click(function(){
		$(".weui-gallery__img").css("background-image",'url("'+ $(this).attr("src") +'")');
		$(".weui-gallery").show();
	})
})

function closemyself(obj){
	$(obj).hide();	
}
		


function GetQueryString(name) {
    var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
    var r = window.location.search.substr(1).match(reg);
    if (r != null) return unescape(r[2]); return null;
}

function checkInput(selector,tip){
	if(validater.empty($(selector).val()) ){
		$.toptip(tip, 'warning');
		return false;
	}
	return true ;
}

function tip(a,c){
	if( c == 'e'){
		$.toptip(a, 'error');
	}else if(c == 'w'){
		$.toptip(a, 'warning');
	}else{
		$.toptip(a, 'success');
	}
}

//setTimeout(function() {
//	forward('wx/xx');
//}, 500);

var slv = selectorVal ;
function selectorVal(selector){
	if($(selector).val()!=undefined)
		return $(selector).val();
	return "" ;
};

/**
 * 设置url里面的值 #...# 
 */
function format_property(value){
	if(! validater.empty(value) ){
		return value.replace(/\$([\w-#\.*]+)\$/g,function(m,i){
			if(i.indexOf('#')>-1  || i.indexOf('.')>-1 ){
				return	selectorVal(i);						
			}else{
				return eval('('+ i +')' );
			}
		});
	}
	return "";
};

/**
 * ios 表单抬高问题
 * @param selector
 * @returns
 */
function iosInitForm(selector){
	var t  ; 
	$(selector).blur(function(){
		t = setTimeout(function() {
			$(window).scrollTop(0);
		}, 100);
	})
	
	$(selector).click(function(){
		clearTimeout(t);
	});
}

/**
 * 图片压缩
 * @param img
 * @param fileType
 * @returns
 */
function compress(img, fileType) {
    var canvas = document.createElement("canvas");
    var ctx = canvas.getContext('2d');
    var width = img.width;
    var height = img.height;
    canvas.width = width;
    canvas.height = height;
    ctx.fillStyle = "#fff";
    ctx.fillRect(0, 0, canvas.width, canvas.height);
    ctx.drawImage(img, 0, 0, width, height);
    // 压缩
    var base64data = canvas.toDataURL(fileType, 0.1);
    canvas = ctx = null;
    return base64data;
}

/**
 * 获取config-option属性,包含data-options
 */
function getConfig(obj){
	if(obj.attr("data-options") == undefined ){
		if(obj.attr("config-option") == undefined)
			return "";
		return  $.parseJSON( "{"+ toJSONStr( obj.attr("config-option").replace(/[\r\n\t]/g, '').replace(/'/g,'"')) +"}" );		
	}else{
		return  $.parseJSON( "{"+ toJSONStr( obj.attr("data-options").replace(/[\r\n\t]/g, '').replace(/'/g,'"')) +"}" );
	}
	
};

/**
 * str convert str json
 * {a:1,b:'ti' } => {'a':1 ,b:'ti'}
 * @param str
 * @returns
 */
function toJSONStr(str) {
  return str.replace(/([\$\w]+)\s*:/g, function(_, $1){return '"'+$1+'":'});
};

/**
 * 设置 {} 里面的值
 * type null , 选择器的值
 */
function objecter(param , charw){
	var param_temp = {} ;
	for(var property in param){
		var property_val = param[property];
		if( ( typeof property_val == 'string') && property_val.indexOf(charw)==0 && property_val.endWith(charw)){
			param_temp[property]= selectorVal( property_val.substring(charw.length,property_val.length-charw.length));
		}else{
			param_temp[property]=property_val;
		}
	}
	return param_temp ;
};

String.prototype.startWith = function(str) {
	var reg = new RegExp("^" + str);
	return reg.test(this);
}

String.prototype.endWith = function(str) {
	var reg = new RegExp(str + "$");
	return reg.test(this);
}

/**
 * 浏览器类型判断
 * @param osName 
 * @returns bool Or (osName when isName is null) 
 */
function getOs(osName){
	  var os_name = '' ;
	  var userAgent = navigator.userAgent; 
	  var isOpera = userAgent.indexOf("Opera") > -1;  
	  //判断是否Opera浏览器  
	  if (isOpera) {  
		  os_name = "Opera" ;  
	  };   
	  //判断是否Firefox浏览器  
	  if (userAgent.indexOf("Firefox") > -1) {  
		  os_name = "FF";  
	  }   
	  //判断是否chorme浏览器  
	  if (userAgent.indexOf("Chrome") > -1){  
		  os_name = "Chrome";  
	  }  
	  //判断是否Safari浏览器  
	  if (userAgent.indexOf("Safari") > -1) {  
		  os_name = "Safari";  
	  }   
	  //判断是否IE浏览器  
	  if (userAgent.indexOf("compatible") > -1 && userAgent.indexOf("MSIE") > -1 && !isOpera) {  
		  os_name = "IE";  
	  }  
	  //判断是否Edge浏览器  
	  if (userAgent.indexOf("Trident") > -1) {  
		  os_name = "Edge";  
	  }; 
	  if(osName != null){
		  return osName == os_name ;
	  }else{
		  return os_name ;
	  }
}

// -----------------自动化操作-----------------------
var config = [ "selecter" , "form_submit","detail_get" , "detail_post","echart", "auto"] ;

$(function(){
	setTimeout(function(){
		for(var  i  =0;i<config.length ;i++){
//			try{  
				eval('(init_'+ config[i]+'( config[i] )' +')');				
//			}catch(e){
//				console.log(e);
//			}
		}
	}, 50);
	
//  var vConsole = new VConsole();
})


function init_selecter(obj){
	var selectors = $('.jui-'+obj) ;
	for(var i=0;i< selectors.length; i++ ){
		var config  = getConfig(selectors.eq(i)) ;
		init_select(config,selectors.eq(i));
	}
}

function init_form_submit(obj){
	var selectors = $('[type-option="'+obj+'"],.jui-'+obj);
	for(var i=0; i< selectors.length; i++){
		var config = getConfig(selectors.eq(i));
		$(config.submit).data("config",config);
		$(config.submit).data("parents",selectors.eq(i));
		// 绑定表单的验证
		validate.init(config.validate,selectors.eq(i));
		$(config.submit).click(function(){
			var config = $(this).data("config");
			var parents_obj = $(this).data("parents").find("[type-name]");
			if(! validate.submit(config.validate,$(this).data("parents") )){
				return ;
			}
			var param = objecter( gdv(config.param,{}),'$');
			if(!validater.empty(config.prev_sumit_func)){
				param = eval('('+ config.prev_sumit_func +'(param)' +')');
			}
			for(var j=0; j< parents_obj.length;j++ ){
				if( parents_obj.eq(j).attr("type-value") == 'h' ){
					if( parents_obj.eq(j).attr("type-category") == 'date' ){
						param[parents_obj.eq(j).attr("type-name")] = new Date( parents_obj.eq(j).html() );	
					}else{
						param[parents_obj.eq(j).attr("type-name")] = parents_obj.eq(j).html();	
					}
				}else{
					if( parents_obj.eq(j).attr("type-category") == 'date' ){
						param[parents_obj.eq(j).attr("type-name")] = new Date( parents_obj.eq(j).val() );
					}else{
						param[parents_obj.eq(j).attr("type-name")] = parents_obj.eq(j).val();
					}
				}
			}
			if(config.before != null){
				if(! eval('('+ config.before+'()' +')')){
					return ;
				}
			}
			// 提交数据
			commonAjax(gdv(config.method,"POST") , localUrl+ format_property(config.url), param,function(data){
				if(config.success != null){
					eval('('+ config.success+'(data)' +')');
				}
			}, function(){
				if(config.error != null){
					eval('('+ config.error+'()' +')');					
				}
			});
		});
	}
}

function init_auto(obj){
	var selectors = $('.jui-'+obj) ;
	for(var i=0 ; i < selectors.length;i++){
		var config = getConfig(selectors.eq(i)) ;
		config.idseq = i ;
		commonAjax( gdv(config.method,"POST") , 
				localUrl + format_property(config.url) , 
				( (config.method == 'GET')?'': (  objecter( gdv(config.data,{}),'$') )  ) ,function(data){
			if(isOK(data)){
				if( config.before != null ){
					data = eval('('+ config.before+'(data)' +')');	
				}
				selectors.eq(config.idseq).html(selectors.eq(config.idseq).html().format(data.data) );
				// 避免加载数据较慢的情况
				selectors.eq(config.idseq).show();
			}
		});
	}
}

function init_detail_post(obj){
	var selectors = $('[type-option="'+obj+'"],.jui-'+obj) ;
	for(var i=0 ; i < selectors.length;i++){
		var config = getConfig(selectors.eq(i)) ;
		var childs = selectors.eq(i).find("[type-name]");
		postAjax(localUrl+  format_property(config.url),  objecter( gdv(config.param,{}),'$'),  function(data){
			if(data.status == status_code.OK){
				for(var j=0;  j < childs.length;j++){
					if(childs.eq(j).attr("type-value") == 'h' ){
						childs.eq(j).html( data.data[childs.eq(j).attr("type-name")] ) ;
					}else{
						childs.eq(j).val( data.data[childs.eq(j).attr("type-name")] ) ;
					}
				}
			}
			if(config.success != null ){
				eval('('+ config.success+'(data)' +')');
			}
		},function(){
			if(config.error != null){
				eval('('+ config.error+'()' +')');		
			}
		} )
	}
}

function init_detail_get(obj){
	var selectors = $('[type-option="'+obj+'"],.jui-'+obj) ;
	if(obj != 'detail_get' ){ 	//手动调用加载
		selectors = $(obj);
	}
	for(var i=0 ; i < selectors.length;i++){
		var config = getConfig(selectors.eq(i)) ;
		var childs = selectors.eq(i).find("[type-name]");
		getAjax(localUrl+  format_property(config.url), function(data){
			if(data.status == status_code.OK){
				for(var j=0;  j < childs.length;j++){
					if(childs.eq(j).attr("type-value") == 'h' ){
						childs.eq(j).html( data.data[childs.eq(j).attr("type-name")] ) ;
					}else if(childs.eq(j).attr("type-value") == 'ch'){
						childs.eq(j).html( data.data.data[childs.eq(j).attr("type-name")] ) ;
					}
					else{
						childs.eq(j).val( data.data[childs.eq(j).attr("type-name")] ) ;
					}
				}				
			}
			if(config.success != null ){
				eval('('+ config.success+'(data)' +')');
			}
		},function(){
			if(config.error != null){
				eval('('+ config.error+'()' +')');		
			}
		})
	}
}

function init_echart(obj){
	var selectors = $(".jui-"+obj);
	if(obj != 'echart' ){ 	//手动调用加载
		selectors = $(obj);
	}
	for(var i=0; i< selectors.length; i++){
		var object = getConfig(selectors.eq(i));
		commonAjax( gdv(object.method,"POST") , 
				localUrl + format_property(object.url) , ( (object.method == 'GET')?'': (  objecter( gdv(object.data,{}),'$') )  ) ,function(data){
			if(data.status == status_code.OK){
				var dataTemp ;
				if(validater.empty(data.data)){
					return ;
				} 
				if( format_property(object.url).indexOf("paged")>-1  ){
					dataTemp = data.data.data ;					
				}else{
					dataTemp = data.data ;
				}
				var x_value =[];
				var y_value =[];
				for(var i=0;i< dataTemp.length; i++){
					x_value.push(dataTemp[dataTemp.length-i-1][object.x] );
					y_value.push(dataTemp[dataTemp.length-i-1][object.y])
				}
				object.x=x_value;
				object.y=y_value;
				if(!validater.empty(object.beforeEchart)){
					object = eval('('+ object.beforeEchart+'(object,dataTemp)' +')');
				}
				echartInit(object);
				if(!validater.empty(object.success) ){
					object.success();					
				}
			}
		});
	}
}

var validate = {
		_config:{tigger:'submit',style:'pop'},
		init:function(_config , parentobj){
			if(!validater.empty(_config)){
				this._config =$.extend(this._config,_config);
			}
			_config = this._config ;
			validate._initTip();
			if(!validater.empty(_config) && _config.tigger.indexOf("focusout") >-1 ){
				parentobj.find("[validate]").blur(function(){
					var returnMsg = validate.judgeElement(this);
					if(!validater.empty(returnMsg)){
						validate.showInfo(this,returnMsg);
					}else{
						validate._initTip(this);
					}
				})
			}
		},
		submit:function(_config , parentobj){
			if(!validater.empty(_config)){
				this._config =$.extend(this._config,_config);
			}
			_config = this._config ;
			validate._initTip();
			if(!validater.empty(_config) ){
				if(_config.switch_flag) { return ; }
				for(var i=0; i< parentobj.find("[validate]").length;i++){
					var returnMsg = validate.judgeElement(parentobj.find("[validate]")[i]);
					if(!validater.empty(returnMsg)){
						validate.showInfo(parentobj.find("[validate]")[i],returnMsg);
						//aimAt(parentobj.find("[validate]")[i]);
						return false;
					}
				}
				return true ;
			}
		},
		showInfo:function(thisObj,tip){
			if(this._config.style.indexOf("color")!=-1 ){
				$(thisObj).addClass("validate_input_error_color");
			}
			if(this._config.style.indexOf("pop")!=-1){
				$.toptip(tip, 'warning');
			}
			if(this._config.style.indexOf("text")!=-1){
				$(this.textSelector).html(tip)
			}
			if(this._config.style.indexOf("next")!=-1){
				layer.tips(tip, thisObj);
			}
			if(this._config.style.indexOf("wave")!=-1){
				$(thisObj).addClass("validate_input_error_wave");
			}
		},
		judgeElement:function(thisObj){
			var validate_types = $(thisObj).attr("validate").split(",");
			if( validate_types!=null && validate_types.length <1 ){
				return ;
			}
			for(var i=0;i< validate_types.length;i++){
				var validate_temp = validate_types[i].split(":");
				var validate_tip = "" ;
				var validate_type = validate_temp[0];
				if(validate_temp.length == 2){
					validate_tip = validate_temp[1] ;
				}
				if(validate_type == 'empty'){
					if(validater.empty(selectorVal(thisObj))){
						return getVal(validate_tip ,"输入不能为空");
					}
				}
				if(validate_type == 'email'){
					if(!validater.email(selectorVal(thisObj))){
						return getVal(validate_tip,"请输入正确的邮箱");
					}
				}
				if(validate_type == 'num'){
					if(!validater.num(selectorVal(thisObj))){
						return getVal(validate_tip, "请输入数字");
					}
				} 
				if(validate_type == 'phone'){
					if(!validater.phone(selectorVal(thisObj))){
						return getVal(validate_tip,"请输入正确的手机号码");
					}
				}
				if(validate_type == "character"){
					if(!validater.character(selectorVal(thisObj))){
						return getVal(validate_tip, "请输入字母");
					}
				}
				if(validate_type == "chinese"){
					if(!validater.chinese(selectorVal(thisObj))){
						return getVal(validate_tip,"请输入中文");
					}
				}
				if(validate_type == "zero"){
					if(!validater.zero(selectorVal(thisObj))){
						return getVal(validate_tip ,"请输入非0数字");
					}
				}
				if(validate_type == 'cardNO'){
					if(!validater.cardNO(selectorVal(thisObj))){
						return getVal(validate_tip, "请输入正确的身份证号码");
					}
				}
			}
			return "" ;
		},
		_initTip:function(obj){
			$(this.textSelector).html("");
			if(obj!=null){
				$(obj).removeClass("validate_input_error_color");
				$(obj).removeClass("validate_input_error_wave");
			}else{
				$("input[class*='validate']").removeClass("validate_input_error_color");
				$("select[class*='validate']").removeClass("validate_input_error_color");
				$("input[class*='validate']").removeClass("validate_input_error_wave");
				$("select[class*='validate']").removeClass("validate_input_error_wave");
			}
		}
}

